--sample script to create a 25 mb db on the default install paths for logs and Dbs
--with a Domain user identified here as useraccount
--this script is operated by administrator on the local server, the name of the db for this script is
--Sample25mb which needs to be changed each time for a different customer



IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'Sample25mb')
	DROP DATABASE [Sample25mb]
GO

CREATE DATABASE [Sample25mb]  ON (NAME = N'Sample25mb_Data', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL\data\Sample25mb_Data.MDF' , SIZE = 25, FILEGROWTH = 10%) LOG ON (NAME = N'Sample25mb_Log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL\data\Sample25mb_Log.LDF' , SIZE = 1, FILEGROWTH = 10%)
 COLLATE SQL_Latin1_General_CP1_CI_AS
GO

exec sp_dboption N'Sample25mb', N'autoclose', N'false'
GO

exec sp_dboption N'Sample25mb', N'bulkcopy', N'false'
GO

exec sp_dboption N'Sample25mb', N'trunc. log', N'false'
GO

exec sp_dboption N'Sample25mb', N'torn page detection', N'true'
GO

exec sp_dboption N'Sample25mb', N'read only', N'false'
GO

exec sp_dboption N'Sample25mb', N'dbo use', N'false'
GO

exec sp_dboption N'Sample25mb', N'single', N'false'
GO

exec sp_dboption N'Sample25mb', N'autoshrink', N'false'
GO

exec sp_dboption N'Sample25mb', N'ANSI null default', N'false'
GO

exec sp_dboption N'Sample25mb', N'recursive triggers', N'false'
GO

exec sp_dboption N'Sample25mb', N'ANSI nulls', N'false'
GO

exec sp_dboption N'Sample25mb', N'concat null yields null', N'false'
GO

exec sp_dboption N'Sample25mb', N'cursor close on commit', N'false'
GO

exec sp_dboption N'Sample25mb', N'default to local cursor', N'false'
GO

exec sp_dboption N'Sample25mb', N'quoted identifier', N'false'
GO

exec sp_dboption N'Sample25mb', N'ANSI warnings', N'false'
GO

exec sp_dboption N'Sample25mb', N'auto create statistics', N'true'
GO

exec sp_dboption N'Sample25mb', N'auto update statistics', N'true'
GO

if( (@@microsoftversion / power(2, 24) = 8) and (@@microsoftversion & 0xffff >= 724) )
	exec sp_dboption N'Sample25mb', N'db chaining', N'false'
GO

use [Sample25mb]
GO

if not exists (select * from dbo.sysusers where name = N'BUILTIN\Administrators' and uid < 16382)
	EXEC sp_grantdbaccess N'BUILTIN\Administrators', N'BUILTIN\Administrators'
GO

if not exists (select * from dbo.sysusers where name = N'DOMAIN\useraccount' and uid < 16382)
	EXEC sp_grantdbaccess N'Domain\useraccount', N'DOMAIN\useraccount'
GO

exec sp_addrolemember N'db_owner', N'BUILTIN\Administrators'
GO

exec sp_addrolemember N'db_owner', N'DOMAIN\useraccount'
GO

